home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok59.lha
/
AmokEd_V1.02b
/
txt
/
EdOErr.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
6KB
|
307 lines
(*************************************************************************
:Program. EdOErr.mod
:Contents. Commands for AmokEd
:Author. Hartmut Goebel
:Language. Oberon
:Translator. Amiga Oberon Compiler V1.17.1
:Imports. SupLib (Hartmut Goebel)
:History. V0.1, 23 Mar 1991 Hartmut Goebel
:Date. 14 Apr 1991 13:08:26
*************************************************************************)
MODULE EdOErr;
IMPORT
d: Dos,
e: Exec,
edD: EdDisplay,
edE: EdErrors,
edG: EdGlobalVars,
edK: EdKeyboard,
edL: EdLowLevel,
eGd: EdGadgets,
eMn: EdMenu,
g: Graphics,
I: Intuition,
lst: EdLists,
ol: OberonLib,
sl: SupLib,
str: Strings,
sys: SYSTEM;
CONST
MsgFile = "Oberon:Fehler-Meldungen"
Maxerrs = 256;
TYPE
ObError = STRUCT
errNum, line, column: LONGINT;
END;
extern PROC *proc;
ubyte *ob_msgfile = NULL;
uword errtable[MAXERRS];
(* ----------------------------------------------------------------------- *)
PROCEDURE obReadBuffer(name: edG.StringPtr;
VAR len: LONGINT; errstr: edG.StringPtr): edG.StringPtr;
VAR
register struct FileLock *lock,*Lock();
register struct FileHandle *handle,*Open();
register struct FileInfoBlock *fib;
register ubyte *buf = 0;
ubyte str[80];
BEGIN
proc->prwindowPtr = (APTR)Ep->Win;
IF( lock = Lock(name,SHAREDlOCK)) {
fib = malloc(sizeof(struct FileInfoBlock));
Examine(lock,fib);
IF(buf = (ubyte * ) malloc(fib->fibsize)) {
handle = Open(name, MODEoLDFILE);
*len = Read(handle,buf,fib->fibsize);
IF( *len != fib->fibsize) {
strcpy(str,"error reading ");
strcat(str, name);
title(str);
Abortcommand = 1;
free(buf);
buf = 0;
END;
Close(handle);
END; else {
title("Out of memory error");
Abortcommand = 1;
END;
free(fib);
UnLock(lock);
END; else {
title(errstr);
Abortcommand = 1;
END;
RETURN (buf);
END;
PROCEDURE obReadErrfile();
VAR
i, count: LONGINT;
ptr: edG.StringPtr;
len: INTEGER;
str: ARRAY 100 OF CHAR;
BEGIN
len = str,Length(edG.Text.name);
(* is suffix = ".MOD" *)
IF len <= 4 THEN RETURN; END;
IF str.Occurs(edG.Text.name,".mod") # len-4 THEN RETURN; END;
(* read error-file *)
edL.Copy(sys.ADR(edG.Text.name),str,len);
str[len] := "e"; str[len+1] := 0X;
IF(!(ptr = obReadBuffer(str,&len,"No errors")))
RETURN;
Ep->errList = (long)ptr;
Ep->errNum = len / sizeof(obError);
Ep->lastErr = -1;
sprintf(str,"%ld errors",Ep->errNum);
title(str);
(* read message-file *)
strcpy(str,MSGFILE);
strcat(str," not found");
IF(!obMsgfile)
IF(obMsgfile = obReadBuffer(MSGFILE,&len,str)) {
i = 0;
count = 1;
ptr = obMsgfile;
errtable[0] = 0;
while( (i < len) && (count < MAXERRS) ) {
IF( *ptr == '\n') {
errtable[count++] = i+1;
*ptr = '\0';
END;
ptr++;
i++;
END;
END;
RETURN;
END;
PROCEDURE obErrQuit()
BEGIN
IF(Ep->errList) {
free(Ep->errList);
Ep->errList = 0;
Ep->errNum = 0;
END;
END obErrQuit;
(* error functions ------------------------------------------------------- *)
PROCEDURE doReaderrs;
BEGIN
obErrQuit;
obReadErrfile;
END doReaderrs;
PROCEDURE doFirsterr;
{
IF(Ep->errNum) {
Ep->lastErr = -1;
doNexterr();
END; else {
title("No errors");
Abortcommand = 1;
END;
END;
uword dir;
PROCEDURE doNexterr;
BEGIN
dir = 0;
IF(Ep->errNum) {
IF(Ep->lastErr < Ep->errNum)
Ep->lastErr++;
doCurrenterr();
END; else {
title("No errors");
Abortcommand = 1;
END;
END doNextErr;
PROCEDURE doPreverr;
BEGIN
dir = 1;
IF(Ep->errNum) {
IF(Ep->lastErr > 0) {
Ep->lastErr--;
doCurrenterr();
END; else {
title("Already first error");
END;
END; else {
title("No errors");
Abortcommand = 1;
END;
END doPreverr;
PROCEDURE doCurrenterr;
VAR
obError *err;
char str[100];
long *estr;
BEGIN
IF (IntuitionBase->ActiveWindow != Ep->Win) {
WindowToFront(Ep->Win);
ActivateWindow(Ep->Win);
END;
IF(Ep->errNum == 0) {
title("No errors");
Abortcommand = 1;
END; else {
IF(Ep->lastErr == -1)
Ep->lastErr = 0;
IF(Ep->errNum == -1) {
title("Errorfile confused because of block-operations");
Abortcommand = 1;
RETURN;
END;
IF(Ep->lastErr >= Ep->errNum) {
title("No more errors");
Abortcommand = 1;
END; else {
textSync();
err = (obError * ) Ep->errList + Ep->lastErr;
IF(err->line == -1) {
IF(dir)
doPreverr();
else
doNexterr();
END; else {
Ep->Column = err->column-2;
IF(Ep->Column < 0)
Ep->Column = 0;
IF(err->line <= Ep->Lines) {
Ep->Line = err->line-1;
textLoad();
textSync();
estr = (long)obMsgfile + (long)errtable[err->errnum];
sprintf(str,"%ld : %s",
Ep->lastErr+1,
estr
);
title(str);
END;
END;
END;
END;
END doCurrenterr;
(* line operations ------------------------------------------------------- *)
PROCEDURE obErrInsline;
VAR
register obError *err;
register int line = Ep->Line;
register int i;
BEGIN
(* search first error *)
err = (obError * ) Ep->errList;
i = 1;
while((err->line < line) && ( i <= Ep->errNum)) {
i++;
err++;
END;
(* increment following error-lines *)
while( i <= Ep->errNum ) {
IF(err->line != -1)
err->line++;
err++;
i++;
END;
END obErrInsline;
PROCEDURE obErrDeline(line: LONGINT);
VAR
register obError *err;
register uword i;
BEGIN
line++;
(* search first error *)
err = (obError * ) Ep->errList;
i = 1;
while((err->line < line) && ( i <= Ep->errNum)) {
i++;
err++;
END;
while(err->line == line) {
err->line = -1;
i++;
err++;
END;
(* decrement following error-lines *)
while( i <= Ep->errNum ) {
IF(err->line != -1)
err->line--;
err++;
i++;
END;
END odErrDeline;
(*-----------------------------------------------------------------------*)
END EdOErr.